package org.example;

import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:何人亮
 * Date:2024-10-20
 * 22:45
 */
public class Test {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        while(sc.hasNextLine()){
            String s=sc.nextLine();
            if(s.equals("-")){
                break;
            }
            Queue<Character> queue=new LinkedList<>();
            for(int i=0;i<s.length();i++){
                char c=s.charAt(i);
                queue.add(c);
            }
            int m=sc.nextInt();
            while(m!=0){
                int h=sc.nextInt();
                if(m==1){
                    String ss=sc.nextLine();
                }
                for (int i = 0; i < h; i++) {
                    char c= queue.poll();
                    queue.add(c);
                }
                m--;
            }
            String s1=new String();
            int size=queue.size();
            for (int i = 0; i < size; i++) {
                Character c=queue.poll();
                String s2= c.toString();
                s1=s1+s2;
            }
            System.out.println(s1);
        }
    }
}
